<?php
class SearchController extends Zend_Controller_Action {
	
	/**
	 * Search result, save search data into session.
	 */
	public function searchlistAction() {
		$this->_helper->viewRenderer->setNoRender (); //view info disabled
		$this->_helper->getHelper ( 'layout' )->disableLayout (); //template disabled
		
		$reset = $this->_getParam("reset");
		if (!empty($reset)) {
			SessionUtil::setProperty(Constant::SEARCH_DATA, null);	
		} else {
			$type = $this->_getParam ( Constant::VAR_SEARCH_DATA_TYPE );
			$from_city = $this->_getParam ( Constant::VAR_SEARCH_DATA_FROM_CITY );
			$to_city = $this->_getParam ( Constant::VAR_SEARCH_DATA_TO_CITY );
			$from_country = $this->_getParam ( Constant::VAR_SEARCH_DATA_FROM_COUNTRY );
			$to_country = $this->_getParam ( Constant::VAR_SEARCH_DATA_TO_COUNTRY );
			$latest_arrival_time = $this->_getParam ( Constant::VAR_SEARCH_DATA_LASTEST_ARRIVAL_DATE );
			$status = $this->_getParam ( Constant::VAR_SEARCH_DATA_STATUS );
			$keyword = $this->_getParam ( constant::VAR_SEARCH_DATA_KEYWORD );
			$data = array (Constant::VAR_SEARCH_DATA_KEYWORD => $keyword, Advertisement::TYPE => $type, Constant::VAR_SEARCH_DATA_FROM_COUNTRY => $from_country, Constant::VAR_SEARCH_DATA_TO_COUNTRY => $to_country, Constant::VAR_SEARCH_DATA_FROM_CITY => $from_city, Constant::VAR_SEARCH_DATA_TO_CITY => $to_city, Constant::VAR_SEARCH_DATA_LASTEST_ARRIVAL_DATE => $latest_arrival_time, Advertisement::STATUS => $status );
			// save search option to session
			SessionUtil::setProperty ( Constant::SEARCH_DATA, $data );
		}
		
		$config = Zend_Registry::get("config");
		$this->_redirect($config->baseurl);
		
	}
}
?>